﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EPiServer.Core;

namespace EPiBoost.Core.Extensions
{
	public static class ContentAreaExtensions
	{
		public static T GetFirst<T>(this ContentArea contentArea)
		{
			return contentArea == null ? default(T) : contentArea.Contents.OfType<T>().FirstOrDefault();
		}

		public static PageDataCollection GetAsPageDataCollection(this ContentArea contentArea)
		{
			return new PageDataCollection(contentArea.Contents.OfType<PageData>());
		}

		public static bool WillRender(this ContentArea contentArea)
		{
			return contentArea.FilteredContents.Any();
		}


	}
}
